import type { Recordable } from '@vben/types';

import type { Page } from '../base';

import { requestClient } from '#/api/request';

export namespace LimbDeviceModelApi {
  export interface LimbDeviceModel {
    [key: string]: any;
    id: string;
    name: string;
    code?: string;
    description?: string;
    status?: number;
    isDeleted?: boolean;
    createdAt?: string;
    updatedAt?: string;
    deletedAt?: string;
    devices?: any[];
    firmwares?: any[];
    params?: any[];
  }

  export interface DeviceModelUpdateInput {
    status?: number;
    isDeleted?: boolean;
    createdAt?: string;
    updatedAt?: string;
    deletedAt?: string;
    code?: string;
    description?: string;
    name?: string;
    devices?: string[];
    firmwares?: string[];
    params?: string[];
  }
}

/**
 * 获取设备型号列表
 */
async function getDeviceModelList(params: Recordable<any>) {
  return requestClient.get<Page<LimbDeviceModelApi.LimbDeviceModel>>(
    '/limb/device-model/list',
    { params },
  );
}

/**
 * 创建设备型号
 * @param data 设备型号数据
 */
async function createDeviceModel(
  data: LimbDeviceModelApi.DeviceModelUpdateInput,
) {
  return requestClient.post('/limb/device-model', data);
}

/**
 * 更新设备型号
 *
 * @param id 设备型号 ID
 * @param data 设备型号数据
 */
async function updateDeviceModel(
  id: string,
  data: LimbDeviceModelApi.DeviceModelUpdateInput,
) {
  return requestClient.put(`/limb/device-model/${id}`, data);
}

/**
 * 删除设备型号
 * @param id 设备型号 ID
 */
async function deleteDeviceModel(id: string) {
  return requestClient.delete(`/limb/device-model/${id}`);
}

/**
 * 获取设备型号选项
 */
async function getDeviceModelOptions() {
  return requestClient.get(`/limb/device-model/options`);
}

export {
  createDeviceModel,
  deleteDeviceModel,
  getDeviceModelList,
  getDeviceModelOptions,
  updateDeviceModel,
};
